# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pygtksourceview
pkgbase=mingw-w64-${_realname}2
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}2"
pkgver=2.10.1
pkgrel=1
pkgdesc="Python bindings for gtksourceview2 (mingw-w64)"
arch=(any)
url="https://www.gnome.org"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gtksourceview2>=2.10.0"
         "${MINGW_PACKAGE_PREFIX}-python2-pygtk>=2.17.0")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-gobject2"
             "intltool")
options=('staticlibs' 'strip')
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.bz2
        python-m4.patch)
sha256sums=('b4b47c5aeb67a26141cb03663091dfdf5c15c8a8aae4d69c46a6a943ca4c5974'
            '6be636f9ef2715c4bae960f4733f6e36d5d002f62c8d7a652a5df5c6fd746315')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  #patch -p1 -i ${srcdir}/python27.patch
  #patch -p1 -i ${srcdir}/no-undefined.patch
  patch -p1 -i ${srcdir}/python-m4.patch
  autoreconf -fi
  #WANT_AUTOMAKE=latest ./autogen.sh
}

build() {
  cd "$srcdir"

  rm -rf python2-build
  mkdir python2-build
  #cp -r ${_realname}-${pkgver} ${builddir}
  pushd python2-build
    export lt_cv_deplibs_check_method='pass_all'
    PYTHON=${MINGW_PREFIX}/bin/python2 \
    ../${_realname}-${pkgver}/configure --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --disable-static \
      --disable-docs

    make VERBOSE=1
  popd
}

package() {
  cd python2-build
  make DESTDIR="${pkgdir}" install
}
